package com.hw.springcloud;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Classname: orderZKController
 * @Description: zookeeper的order控制类
 * @Date: 2021/7/6
 * @Author: huwei
 */
@RestController
public class OrderZkController {

    /**
     * 服务提供者在zookeeper注册的名称
     */
    public static final String INVOKE_URL = "http://cloud-provider-payment8004";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/test")
    public String test(){
        return "本地测试正常";
    }

    @GetMapping("/linkTest")
    public String linkTest(){
        return restTemplate.getForObject(INVOKE_URL+"/linkTest",String.class);
    }

    /**
     * 测试消费端是否注册zookeeper成功
     * @return
     */
    @GetMapping("/consumer/orderZk/info")
    public String paymentInfo(){
        System.out.println(INVOKE_URL+"/payment/zk");
        return restTemplate.getForObject(INVOKE_URL + "/payment/zk", String.class);
    }
}
